package file.day9_19.day04.homework;

import java.io.*;
import java.util.Scanner;

public class Test2WriteTxt {
    public static void main(String[] args) {
        try(
                PrintWriter pw = new PrintWriter(
                        new BufferedWriter(
                                new OutputStreamWriter(
                                        new FileOutputStream("pw.txt",true)
                                )
                        ),true
                );
        ){
            while (true){
                Scanner scanner = new Scanner(System.in);
                System.out.println("请输入内容：");
                String line = scanner.nextLine();
                if(line.equals("exit")) break;
                pw.println(line);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
